package com.example.dynamicschedule.service.impl;

import com.example.dynamicschedule.bean.CkOrderAchievementForm;
import com.example.dynamicschedule.dao.CkOrderAchievementFormMapper;
import com.example.dynamicschedule.service.CkOrderAchievementFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CkOrderAchievementFormServiceImpl implements CkOrderAchievementFormService {
    @Autowired
    private CkOrderAchievementFormMapper ckOrderAchievementFormMapper;

    @Override
    public  Map<String, CkOrderAchievementForm> selectAll() {
        List<CkOrderAchievementForm> ckOrderAchievementForms = ckOrderAchievementFormMapper.selectAll();
        Map<String, CkOrderAchievementForm> ckOrderAchievementFormHashMap = new HashMap<>();
        ckOrderAchievementForms.stream().forEach(ckOrderAchievementForm -> {
            String collectorId = ckOrderAchievementForm.getCollectorId();
            ckOrderAchievementFormHashMap.put(collectorId,ckOrderAchievementForm);
        });
        return ckOrderAchievementFormHashMap;
    }

    @Override
    public void insertForeach(List<CkOrderAchievementForm> addCkOrderAchievementForm) {
        ckOrderAchievementFormMapper.insertForeach(addCkOrderAchievementForm);
    }

    @Override
    public void updateForeach(List<CkOrderAchievementForm> updateCkOrderAchievementForm) {
        ckOrderAchievementFormMapper.updateForeach(updateCkOrderAchievementForm);
    }
}
